package edu.uis.csc478.spring09.threeoxen.persistence;

import edu.uis.csc478.spring09.threeoxen.persistence.pantry.impl.PantryObjectFactoryImpl;
import edu.uis.csc478.spring09.threeoxen.persistence.pantry.PantryObjectFactory;
import edu.uis.csc478.spring09.threeoxen.persistence.user.UserObjectFactory;
import edu.uis.csc478.spring09.threeoxen.persistence.user.impl.UserObjectFactoryImpl;
import edu.uis.csc478.spring09.threeoxen.persistence.store.StoreObjectFactory;
import edu.uis.csc478.spring09.threeoxen.persistence.store.impl.StoreObjectFactoryImpl;

public class PersistenceFactoryLoader {

    private static PersistenceFactoryLoader instance = new PersistenceFactoryLoader();

    private UserObjectFactory userObjectFactory = null;
    private PantryObjectFactory pantryObjectFactory = null;
    private StoreObjectFactory storeObjectFactory = null;

    private PersistenceFactoryLoader() {

    }

    public static PersistenceFactoryLoader getInstance() {
        return instance;
    }

    public PantryObjectFactory getPantryObjectFactory() {
        if(pantryObjectFactory == null) {
            pantryObjectFactory = new PantryObjectFactoryImpl();
        }
        return pantryObjectFactory;
    }

    public UserObjectFactory getUserObjectFactory() {
        if(userObjectFactory == null) {
            userObjectFactory = new UserObjectFactoryImpl();
        }
        return userObjectFactory;
    }

    public StoreObjectFactory getStoreObjectFactory() {
        if(storeObjectFactory == null) {
            storeObjectFactory = new StoreObjectFactoryImpl();
        }
        return storeObjectFactory;
    }

}
